var a = getApp();

Page({
    data: {
        language: "",
        shareData: {},
        info: {},
        page: 1,
        isLoadMore: !0,
        total_page: 0
    },
    onLoad: function(a) {
        this._getData(), this.getShare();
    },
    onReady: function() {
        var a = wx.getStorageSync("langIndex");
        this.setData({
            language: a.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.isLoadMore ? this.getMoreData() : console.log("没有更多数据");
    },
    onShareAppMessage: function() {
        return {
            title: this.data.shareData.share_title,
            imageUrl: this.data.shareData.share_img,
            path: "/packageB/member/group_buy/group_buy_list/group_buy_list"
        };
    },
    _getData: function() {
        var t = this, e = a.getNetAddresss("plugin.together-purchase.api.index.getTogetherData");
        e += "&art=polymerization", a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    isLoadMore: !0,
                    total_page: e.data.polymerization.last_page
                }), t.data.total_page || t.setData({
                    total_page: 0
                }), t.setData({
                    info: e.data.polymerization.data
                })) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            }
        });
    },
    getShare: function() {
        var t = this, e = a.getNetAddresss("plugin.together-purchase.api.index.getTogetherData");
        e += "&art=getShare", a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? t.setData({
                    shareData: e.data.getShare
                }) : wx.showToast({
                    icon: "none",
                    title: e.msg,
                    duration: 1500
                });
            }
        });
    },
    getMoreData: function() {
        var t = this;
        if (this.setData({
            isLoadMore: !1
        }), !(this.data.page >= this.data.total_page)) {
            var e = this.data.page;
            e += 1, this.setData({
                page: e
            });
            var o = a.getNetAddresss("plugin.together-purchase.api.index.getTogetherData");
            o += "&page=" + this.data.page + "&art=polymerization", a._getNetWork({
                url: o,
                success: function(a) {
                    var e = a.data;
                    if (t.setData({
                        isLoadMore: !0
                    }), 1 == e.result) {
                        var o = e.data.polymerization.data;
                        t.setData({
                            info: t.data.info.concat(o)
                        });
                    } else {
                        var i = t.data.page;
                        i--, t.setData({
                            page: i,
                            isLoadMore: !1
                        }), wx.showToast({
                            icon: "none",
                            title: e.msg,
                            duration: 1500
                        });
                    }
                }
            });
        }
    },
    goGroup: function(a) {
        var t = a.target.dataset.goods_id || a.currentTarget.dataset.goods_id, e = a.target.dataset.activity_id || a.currentTarget.dataset.activity_id;
        console.log(t, e, "参数"), wx.navigateTo({
            url: "/packageA/detail_v2/detail_v2?id=" + t + "&activity_id=" + e + "&name=group_buy"
        });
    }
});